#pragma once

#include"Engine.h"

namespace Advanced2D{
	class Sprite:public Entity{
	private:		
		bool imageload;

		D3DXVECTOR2 position;
		D3DXVECTOR2 velocity;
		D3DXVECTOR2 direction;

	protected:
		Texture* image;
		
		int width, height;
		int animcolumns;
		
		int framestart, frametimer;
		int movestart, movetimer;

		int curframe, totalframe, animdir;

		float rotation, scaling;
		D3DXMATRIX matRotation, matScale;
		void transform();
		D3DCOLOR color;
	public:
		Sprite();
		virtual ~Sprite();

		bool loadImage(std::string filename, D3DCOLOR transcolor = D3DCOLOR_XRGB(255,0,255));
		void setImage(Texture* image);

		virtual void move();
		virtual void animate();
		virtual void draw();		
		
		void setPosition(const D3DXVECTOR2& v) { position = v ; }		
		void setPosition(float x, float y) { position = D3DXVECTOR2(x, y); }
		D3DXVECTOR2 getPosition() { return position; }
		int getPositionX() { return (int)position.x; }
		void setPositionX(float value){ position.x = value;; }
		int getPositionY() { return (int)position.y; }
		void setPositionY(float value){ position.y = value; }

		void setVelocity(const D3DXVECTOR2& v) { velocity = v; }		
		void setVelocity(float x, float y) { velocity = D3DXVECTOR2(x,y); }
		D3DXVECTOR2 getVelocity() { return velocity; }

		void setDirection(int x, int y) { direction = D3DXVECTOR2((float)x, (float)y); }
		D3DXVECTOR2 getDirection() { return direction; }		
		void setDirectionX(int value) { direction.x = (float)value; }
		int getDirectionX(){ return (int)direction.x; }
		void setDirectionY(int value) { direction.y = (float)value; }
		int getDirectionY(){ return (int)direction.y; }

		void setSize(int width, int height) { this->width = width; this->height = height; }
		void setWidth(int value) { width = value; }
		int getWidth() { return width; }
		void setHeight(int value) { height = value; }
		int getHeight() { return height; }
		void setAnimcolumns(int value) { animcolumns = value; }
		int getAnimcolumns() { return animcolumns; }

		void setFrameTime(int millisecond) { frametimer = millisecond; }
		int getFrameTime() { return frametimer; }
		void setMoveTime(int millisecond) { movetimer = millisecond; }
		int getMoveTime() { return movetimer; }

		void setCurFrame(int value) { curframe = value; } 
		int getCurFrame() { return curframe; }
		void setTotalFrame(int value) { totalframe = value; }
		int getTotalFrame() { return totalframe; }
		void setAnimdir(int value) { animdir = value; }
		int getAnimdir() { return animdir; }

		void setRotation(float value) { rotation = value; }
		float getRotation() { return rotation; }
		void setScale(float value) { scaling = value; }
		float getScale() { return scaling; }
	};
};